package com.example.demofdfs.util;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.FileUtils;
import org.apache.tika.Tika;

public class VFile {
	/**
	 * text/plain
	 * application/x-sh
	 * @param args
	 * @throws IOException
	 */
     public static void main(String[] args) throws IOException {
		String[] filenames = {
				"doc/命令笔记.txt",
				"doc/mysql-apt-repo-quick-guide-en.html-chapter.zip",
				"file/test.sh",
				"file/test.txt",
				"file/script.awk",
				"file/ss.gg",
				"filse/",
				};
		
		for(String filename : filenames) {
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			File file = new File(filename);
			FileUtils.copyFile(file, baos);
			InputStream in = new FileInputStream(file);
			Tika tika = new Tika();
			String type = tika.detect(in);
			System.out.println(type);
			in.read();
			
		}
	}
	
	
	
}
